package com.liuh.ssh2.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.liuh.ssh2.dao.UserDao2;
import com.liuh.ssh2.pojo.User;

@Service("userService")
public class UserServiceImpl implements UserService{
	
	@Resource(name="userDao")
	UserDao2 userDao;

	public UserDao2 getUserDao() {
		return userDao;
	}

	public void setUserDao(UserDao2 userDao) {
		this.userDao = userDao;
	}

	@Override
	public User getUserById(int id) {
		// TODO Auto-generated method stub
		return userDao.getUserById(id);
	}

	@Override
	public void addUser(User u) {
		// TODO Auto-generated method stub
		userDao.saveUser(u);
		if("你好".equals(u.getUserName())) {
			throw new RuntimeException("大哥我错了");
		}
	}

	@Override
	public User getUserById(User u) {
		// TODO Auto-generated method stub
		return userDao.getUserById(u);
	}

	@Override
	public List<User> getUserPage(int pageNo, int pageSize) {
		// TODO Auto-generated method stub
		return userDao.getUserPage(pageNo, pageSize);
	}

	@Override
	public void updUser(User u) {
		// TODO Auto-generated method stub
		userDao.updUser(u);
	}

}
